package net.zjitc;

import net.zjitc.ex01.Person;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * Created by Administrator on 2017/11/6.
 */
public class TestThree {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InstantiationException, NoSuchFieldException, InvocationTargetException {
        Class clazz = Class.forName("net.zjitc.ex01.Person");
        Person person = (Person) clazz.newInstance();
        Constructor[] constructor = clazz.getConstructors();
        Field field = clazz.getField("name");
        System.out.println(field);

        Method[] method  = clazz.getMethods();
        for (Method m:method) {
            if(m.getName().equals("speck")) {
                m.invoke(person, "zs", 20);
            }
            System.out.println(m.getName());
        }
    }
}
